/*
 * Project:     My Project Work, Copyright (C) 2011
 * Created at:  05.08.2011
 */
package de.myprojectwork.model.dto;

import java.util.Date;
import org.apache.commons.lang3.time.DateFormatUtils;

/**
 * Tabelle <code>TODO</code>
 * 
 * @author Chris Holdschuh
 */
public class Todo extends AbstractDto {
    
    private int         fkProject;
    private int         fkParent;
    private int         orderNumber;
    private Date        targetDate;
    private int         statusPercent;
    private String      text;
    
    private Project     project;
    private Todo        parent;

    public Todo() {
    }

    public int getFkParent() {
        return fkParent;
    }

    public void setFkParent(int fkParent) {
        this.fkParent = fkParent;
    }

    public int getFkProject() {
        return fkProject;
    }

    public void setFkProject(int fkProject) {
        this.fkProject = fkProject;
    }

    public int getOrderNumber() {
        return orderNumber;
    }

    public void setOrderNumber(int orderNumber) {
        this.orderNumber = orderNumber;
    }

    public Todo getParent() {
        return parent;
    }

    public void setParent(Todo parent) {
        this.parent = parent;
        fkParent = parent != null ? parent.getId() : 0;
    }

    public Project getProject() {
        return project;
    }

    public void setProject(Project project) {
        this.project = project;
        fkProject = project.getId();
    }

    public int getStatusPercent() {
        return statusPercent;
    }

    public void setStatusPercent(int statusPercent) {
        this.statusPercent = statusPercent;
    }

    public Date getTargetDate() {
        return targetDate;
    }

    public void setTargetDate(Date targetDate) {
        this.targetDate = targetDate;
    }

    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }

    @Override
    public String toString() {
        return getClass().getSimpleName() + " {"
                + "id=" + getId() + ", "
                + "fkProject=" + fkProject + ", "
                + "fkParent=" + fkParent + ", "
                + "orderNumber=" + orderNumber + ", "
                + "targetDate=" + (targetDate != null ? DateFormatUtils.format(targetDate, "dd.MM.yyyy") : "null") + ", "
                + "text=" + text + ", "
                + "update=" + DateFormatUtils.format(getUpdate(), "dd.MM.yyyy") 
                + "}";
        
    }
    
    
}
